<?php
/**
 *
 * Created by PhpStorm.
 * User: zhang-hong
 * Date: 2017/3/7
 * Time: 16:20
 */
class LisJianChaInfoModel extends BaseModel
{
    //获取检查信息列表
    public function getJianchaInfo($zhuyuan_id,$yiyuan_id)
    {
        $this->yiyuan_id = $yiyuan_id;
        $data = DB::select("a.id","a.jiancha_code","a.jiancha_keshi_name","a.jiancha_leibie",
            "a.jiancha_time","a.songjian_wu","a.shenqing_zhe_name","a.shenqing_keshi_name","a.jiancha_mingcheng",
            "a.jiancha_yichangjieguo","a.shenqing_time","a.jiancha_time","a.jiancha_zhuangtai",
            array("a.jianyan_doctor_name","jiancha_zhe_name"),array("a.hedui_doctor_name","hedui_zhe_name"),
            "a.jiancha_time")->from(array("lis_jiancha_info","a"))
            ->where("a.zhixing_id","=",$zhuyuan_id)
            ->and_where("a.yiyuan_id","=",$this->yiyuan_id)
            ->order_by("a.shenqing_time","DESC")
            ->execute()
            ->as_array();
        return $data;
//        $query_sql = "SELECT a.id, a.jiancha_code, a.jiancha_keshi_name, a.jiancha_leibie,
//a.jiancha_time, a.songjian_wu, a.shenqing_zhe_name, a.shenqing_keshi_name, a.jiancha_mingcheng,
//a.jiancha_yichangjieguo, a.shenqing_time, a.jiancha_time, a.jiancha_zhuangtai,
//a.jianyan_doctor_name as jiancha_zhe_name, a.hedui_doctor_name as hedui_zhe_name,a.jiancha_time
//FROM lis_jiancha_info AS a  ".$where_sql." order by a.shenqing_time desc";
//        $jiancha_result_jianyan  = M()->query($query_sql);
    }
    //获取住院患者检查列表
    public function getPacsJianchaInfo($zhuyuan_id,$yiyuan_id)
    {
        $this->yiyuan_id = $yiyuan_id;
        $data = DB::select("a.id","a.zhixing_id",
            array("yiyuan_department_info.keshi_name","jiancha_keshi_name"),
            array("a.jiancha_buwei","jiancha_mingcheng"),array("a.jiancha_time","shenqing_time"))
            ->from(array("pacs_jiancha_info","a"))
            ->join("yiyuan_department_info","left")
            ->on("yiyuan_department_info.code","=","a.zhixing_kebie")
            ->where("a.zhixing_id","=",$zhuyuan_id)
            ->and_where("a.yiyuan_id","=",$yiyuan_id)
            ->execute()
            ->as_array();
        return $data;
    }

    /**
     * 根据检查id获取信息
     * @param $jiancha_id
     * @param $yiyuan_id
     */
    public function getJianchaInfoById($jiancha_id,$yiyuan_id)
    {
        $data = DB::select()
            ->from("lis_jiancha_result")
            ->where("jiancha_result_info_id","=",$jiancha_id)
            ->and_where("yiyuan_id","=",$yiyuan_id)
            ->execute()
            ->as_array();
        return $data;
    }


}